package com.heima.wemedia.controller.v1;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.AdNewsDto;
import com.heima.model.wemedia.dtos.AdScanDto;
import com.heima.model.wemedia.dtos.WmNewsDto;
import com.heima.model.wemedia.dtos.WmNewsPageReqDto;
import com.heima.wemedia.service.AdNewsService;
import com.heima.wemedia.service.WmNewsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/v1/news")
public class WmNewsController {

    @Autowired
    private WmNewsService wmNewsService;

    @Autowired
    private AdNewsService adNewsService;

    /**
     * 查询文章列表
     * @return
     */
    @PostMapping("/list")
    public ResponseResult list(@RequestBody WmNewsPageReqDto dto) {
        return wmNewsService.list(dto);
    }


    /**
     * 发布文章
     * @return
     */
    @PostMapping("/submit")
    public ResponseResult submit(@RequestBody WmNewsDto wmNewsDto) {
        return wmNewsService.submit(wmNewsDto);
    }


    /**
     * 平台端查询自媒体文章列表
     */
    @PostMapping("/list_vo")
    public ResponseResult adminList(@RequestBody AdNewsDto dto) {
        return adNewsService.adminList(dto);
    }


    /**
     * 查看文章
     */
    @GetMapping("/one_vo/{id}")
    public ResponseResult findById(@PathVariable Integer id) {
        return adNewsService.findById(id);
    }

    /**
     * 审核失败
     */
    @PostMapping("/auth_fail")
    public ResponseResult authFail(@RequestBody AdScanDto dto) {
        return adNewsService.authFail(dto);
    }

    /**
     * 审核成功
     */
    @PostMapping("auth_pass")
    public ResponseResult authPass(@RequestBody AdScanDto dto) {
        return adNewsService.authPass(dto);
    }

}
